/*
 * Copyright (c) 2016- 2020 qolome.com Inc. All Rights Reserved.
 * ProjectName: qolome-knowledge
 * FileName: AbstractAuthentication.java
 * Author: jiangfeng@qolome.com
 * Date: 2020/3/15 下午4:44
 * LastModified: 2020/03/15 16:44:15
 */

package com.qolome.knowledge.design.pattern.strategy.demo.authentication;

import com.qolome.utils.web.HttpResult;
import org.apache.commons.lang3.StringUtils;

import java.math.BigDecimal;

/**
 * @author Qolome
 * @version V1.0
 * @Description 抽象认证
 * @date 2020年 03月15日 16:44:01
 */
public abstract class AbstractAuthentication {

    /**
     * 获取登录方式
     * @return 登录方式
     */
    public abstract String getAuthenticationType();

    public abstract String getToken(String uid);


    public HttpResult<String> authentication(String uid,String accessToken) {

        if (!StringUtils.equals(accessToken,getToken(uid))) {
            return HttpResult.<String>builder()
                    .message("认证失败")
                    .exception("token错误")
                    .data("uid")
                    .code(200)
                    .build();
        }
        return HttpResult.success("认证成功", null);
    }

}
